<template>
  <div @keyup.enter="getData()">
    <el-form class="query-form" @submit.prevent :inline="true" :model="params">
      <el-form-item>
        <el-input v-model="params.ind_name" placeholder="产业名查询" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="params.ind_category" placeholder="产业类型" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="params.ins_year" type="number" placeholder="年份" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search" @click="getData()">查询</el-button>
      </el-form-item>
    </el-form>

    <c-table border v-loading="loading" :columns="tableColumns" :data="tableData"></c-table>

    <div class="query-pagination">
      <div></div>
      <el-pagination
        layout="total, prev, pager, next, jumper"
        :current-page.sync="params.index"
        :page-size="params.size"
        :total="totalCount"
        @current-change="getData"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      loading: false,
      params: {
        index: 1,
        size: 15,
        ind_category: '',
        ind_name: '',
        ins_year: '',
      },
      tableName: 'insurance_class',
      tableData: [],
      totalCount: 0,
      tableColumns: [
        { attrs: { label: '产业名', prop: 'ind_name' } },
        { attrs: { label: '产业类型', prop: 'ind_category_name' } },
        { attrs: { label: '保险机构', prop: 'agency_name' } },
        { attrs: { label: '年份', prop: 'ins_year' } },
        { attrs: { label: '地域', prop: 'address_code_name' } },
        { attrs: { label: '保费费率', prop: 'ins_fee' } },
        { attrs: { label: '保险责任', prop: 'ins_res' } },
        { attrs: { label: '单位保额', prop: 'ins_amount' } },
        { attrs: { label: '单位', prop: 'unit' } },
        { attrs: { label: '中央补贴', prop: 'center_fee_rate' } },
        { attrs: { label: '省级补贴', prop: 'pro_fee_rate' } },
        { attrs: { label: '县级补贴', prop: 'county_fee_rate' } },
        { attrs: { label: '地市补贴', prop: 'city_fee_rate' } },
        { attrs: { label: '其它补贴', prop: 'other_fee_rate' } },
        { attrs: { label: '自缴比例', prop: 'self_fee_rate' } },
      ],
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    async getData(index = 1) {
      this.params.index = index
      this.loading = true
      const [res] = await this.$utils.promise(
        this.$api.getData('insurance', this.tableName, this.params, { create_time: 'asc' })
      )
      this.loading = false
      this.tableData = (res && res.data && res.data.data) || []
      this.totalCount = (res && res.data && res.data.totalCount) || 0
    },
  },
}
</script>
<style lang="scss" scoped></style>
